package com.fr.fileTest;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
*作者：furong
*日期：2016年11月18日
*时间：下午6:59:24
*/
public class FileUrl {
    public static void main(String[] args) throws IOException {
        URL url = new URL(
                "http://ho-test.oss.aliyuncs.com/authorization/20161118/17/af5e285c-f3f2-471d-a47e-3851a7bef0b7.2.pdf?Expires=1794820320&OSSAccessKeyId=4aLE8QGSsmACxcyU&Signature=ZD0V7QpLPvI1qhqjqv0YL8NSczE%3D");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setConnectTimeout(3000);
        conn.setReadTimeout(60000);
        conn.connect();
        InputStream is = conn.getInputStream();

        File file = new File("F:\\2.pdf");
        @SuppressWarnings("resource")
        FileInputStream fi = new FileInputStream(file);
        byte[] a = new byte[1024];
        byte[] b = new byte[1024];
        while (is.read(a) > 0) {
            while (fi.read(b) > 0) {
            }
        }
    }
}
